/*
 * hopper_ev2000_interface.h
 *
 *  Created on: 25.12.2012
 *      Author: aska
 */

#ifndef HOPPER_EV2000_INTERFACE_H_
#define HOPPER_EV2000_INTERFACE_H_
#include <windows.h>
#include <stdio.h>
#include <iostream>
//#include "hopper_ev2000_dll.h"
using namespace std;

extern HINSTANCE hopper_dll_handle;


typedef int (__stdcall *t_hopper_init)(void);
//typedef int (__stdcall *t_hopper_init_prepare_mode_d2xx)(char * vpPort_name);
typedef int (__stdcall *t_hopper_init_prepare_mode_d2xx)(int mode, int inp_par, int port_No, char * vpPort_name);
typedef int (__stdcall *t_hopper_init_prepare_mode_d2xx_portNo)(int mode, int port_No);
typedef int (__stdcall *t_hopper_close)(void);
typedef int (__stdcall *t_hopper_set_mode)(char dev_interface_mode_inp);
typedef int (__stdcall *t_hopper_port_open)(char * ser_name);
typedef int (__stdcall *t_hopper_d2xx_open)(char * vpPort_name);
typedef int (__stdcall *t_hopper_send_simple_poll)(char addr);
typedef int (__stdcall *t_hopper_address_poll)(char * addr);
typedef int (__stdcall *t_hopper_prepare_addr)(char addr);
typedef int (__stdcall *t_hopper_prepare)(char * vp_Port_name);
typedef int (__stdcall *t_hopper_test_hopper)(char addr, char vp_hopper_registers[]);
typedef int (__stdcall *t_hopper_request_status)(char addr, char vp_byte_arr[]);
typedef int (__stdcall *t_hopper_put_coins_ack)(char addr, int Coins_count,
		int * Coins_rem, int * Coins_paid, int * Coins_unpaid);

class hopper_ev2000_lib{
public:
	hopper_ev2000_lib(void);
	~hopper_ev2000_lib(void);
	HMODULE h_hopper_ev2000_dll;
	int hopper_ev2000_dll_load(void);
	int dll_free(void);
	t_hopper_init				hopper_init;
	t_hopper_init_prepare_mode_d2xx	hopper_init_prepare_mode_d2xx;
	t_hopper_init_prepare_mode_d2xx_portNo	hopper_init_prepare_mode_d2xx_portNo;
	t_hopper_close				hopper_close;
	t_hopper_set_mode			hopper_set_mode;
	t_hopper_port_open			hopper_port_open;
	t_hopper_d2xx_open			hopper_d2xx_open;
	t_hopper_send_simple_poll	hopper_send_simple_poll;
	t_hopper_address_poll		hopper_address_poll;
	t_hopper_prepare			hopper_prepare;
	t_hopper_test_hopper		hopper_test_hopper;
	t_hopper_request_status		hopper_request_status;
	t_hopper_put_coins_ack		hopper_put_coins_ack;
	char log_file_name[255];	// Log file name
	char log_file_path[255];
	FILE * log_file_ptr;	// Log file pointer
	int log_file_year_day_prev;		// Log file previous day since January 1, for logging one file per day
	int log_file_year_day_pres;		// Log file current day since January 1
	int log_add_str(char * log_str);	// Function to write log string. Adds data in the beginning an and CR in the end of string.
};

#endif /* HOPPER_EV2000_INTERFACE_H_ */
